home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_1.lha
/
6_1
/
6_1b.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
435b
|
18 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ exercise 6.1
/ string concatenation operator
tring operator+(string& st1, string& st2)
char *s1 = st1.p->s;
char *s2 = st2.p->s;
int s1len = strlen(s1);
char *ns = new char[s1len + strlen(s2) + 1];
strcpy(ns, s1);
strcpy(ns + s1len, s2);
string st(ns);
return st;